AS=nasm
CC=gcc
LD=ld
OBJ=objcopy

ASFLAGS=-felf
CCFLAGS=-I./lib/include -fno-stack-protector -nostdlib -fno-builtin
LDFLAGS=-T./link.ld
OBJFLAGS=-R .pdr -R .comment -R .note -S -O binary

all: kernel.com

kernel.com: load.bin kernel.bin
	cat ./load/load.bin kernel.bin > kernel.com

kernel.bin: start.asm kernel.c 
	$(AS) $(ASFLAGS) -o start.elf start.asm
	(cd lib;make)
	$(CC) $(CCFLAGS) -c *.c
	$(LD) $(LDFLAGS) -o kernel.x *.elf *.o ./lib/*.o
	$(OBJ) $(OBJFLAGS)  kernel.x kernel.bin

load.bin: ./load/load.asm 
	(cd load;make)

clean:
	(cd load;make clean)
	(cd lib;make clean)
	rm -rf *.elf *.bin *.o *.x *.com
